﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace WB.Mvc.Forms.Widgets
{
	/// <summary>
	/// A widget for multiline text input.
	/// </summary>
	public class TextArea: Widget
	{
		/// <summary>
		/// Creates an instance of <paramref name="TextArea"/>.
		/// </summary>
		public TextArea() : base(typeof(TextArea).Name)
		{
		}

		/// <summary>
		/// Creates an instance of <paramref name="TextArea"/>.
		/// </summary>
		public TextArea(string name) : base(name)
		{
		}

		/// <summary>
		/// Creates an instance of <paramref name="TextArea"/>.
		/// </summary>
		public TextArea(string name, IDictionary<string, object> attributes) : base(name, attributes)
		{
		}

		public override object Value
		{
			get; set;
		}

		/// <summary>
		/// The widget's html representation.
		/// </summary>
		public override string ToHtml()
		{
			XElement ele = new XElement("textarea", Value);
			foreach (var key in Attributes.Keys)
			{
				ele.Add(new XAttribute(key, Attributes[key]));
			}

			return ele.ToString();
		}
	}
}
